package org.dpes.apriori;

import java.util.HashMap;
import java.util.Map;

public class Elementy {
	
	final private Map<Integer, Element> indeks = new HashMap<Integer, Element>();
	
	private static Elementy singleton; 
	
	public final static int licznosc = 80;
	
	public class Element implements Comparable<Element>{
		
		private int value;
		
		private Element(int n) {
			this.setValue(n);
		}

		private void setValue(int value) {
			this.value = value;
		}

		public int getValue() {
			return value;
		}

		@Override
		public int compareTo(Element o) {
			if (getValue() == o.getValue())
				return 0;
			if (getValue() > o.getValue())
				return -1;
			else
				return 1;
		}
		@Override
		public String toString() {
			return String.valueOf(value);
		}
	}
	
	static public Elementy getSingleton() {
		if (singleton == null) {
			Elementy elementy = new Elementy();
			elementy.inicjujElementy();
			singleton = elementy;
		}
		return singleton;
	}

	private  void inicjujElementy() {
		for (int i = 1; i <= licznosc; i++) {
			Element nowy = new Element(i);
			indeks.put(i, nowy);
		}
	}
	
	public Element podajElement(int n) {
		return indeks.get(n);
	}
}
